'''
Descripttion: 
version: 
Author: jinqian
Date: 2022-05-01 19:58:08
LastEditors: jinqian
LastEditTime: 2022-05-01 20:06:06
'''


from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

from app.config import Config

engine = create_engine(Config.db)

SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

Base = declarative_base(engine)
Base.metadata.create_all(engine)


async def get_db():
    db = SessionLocal()
    try:
        yield db
    finally:
        db.close()
